package cn.darkhorse.common.config;

import cn.darkhorse.common.constant.CommonConstant;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "db")
public class DbTypeConfig {
    //true为开启，false关闭
    private static String type;
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getFrontBracket() {
        if (this.getType().equals(CommonConstant.DB_TYPE_MYSQL)) {
            return "`";
        }
        if (this.getType().equals(CommonConstant.DB_TYPE_SQLSERVER)) {
            return "[";
        }
        return "";
    }

    public String getBackBracket() {
        if (this.getType().equals(CommonConstant.DB_TYPE_MYSQL)) {
            return "`";
        }
        if (this.getType().equals(CommonConstant.DB_TYPE_SQLSERVER)) {
            return "]";
        }
        return "";
    }

    public Boolean isMysql() {
        return this.getType().equals(CommonConstant.DB_TYPE_MYSQL);
    }

    public Boolean isSqlServer() {
        return this.getType().equals(CommonConstant.DB_TYPE_SQLSERVER);
    }
}
